package com.atguigu.common.config.mybatisplus.inject;

import com.baomidou.mybatisplus.core.injector.AbstractMethod;
import com.baomidou.mybatisplus.core.injector.DefaultSqlInjector;
import com.baomidou.mybatisplus.core.metadata.TableInfo;
import com.atguigu.common.config.mybatisplus.customMethod.FindOneById;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author 谭军(tanjun @ bosssoft.com.cn)
 * @Title: <br>
 * @Description: <br>
 * @Date 2024-06-03 15:28
 */
public class CustomInject extends DefaultSqlInjector {
    @Override
    public List<AbstractMethod> getMethodList(Class<?> mapperClass, TableInfo tableInfo) {
        List<AbstractMethod> methodList = super.getMethodList(mapperClass, tableInfo);
        // 自定义
        methodList.add(new FindOneById());
        return methodList;
    }

    /**
     * 如果只需增加方法，保留mybatis plus自带方法，
     * 可以先获取super.getMethodList()，再添加add
     */
//    @Override
//    public List<AbstractMethod> getMethodList(Class<?> mapperClass, TableInfo tableInfo) {
//        List<AbstractMethod> methodList = super.getMethodList(mapperClass,tableInfo);
//        methodList.add(new InsertBatchMethod());
//        methodList.add(new UpdateBatchMethod());
//        methodList.add(new MysqlInsertOrUpdateBath());
//        methodList.add(new PGInsertOrUpdateBath());
//        return methodList;
//    }
}

